/*     */ package com.qmsk.business.info.carSystem.controller;
/*     */ 
/*     */ import com.qmsk.business.info.carSystem.dao.CarSystemDAO;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/carSystem"})
/*     */ public class CarSystemController
/*     */ {
/*  30 */   private static final Logger logger = Logger.getLogger(CarSystemController.class);
/*     */ 
/*     */   @Autowired
/*     */   private CarSystemDAO dao;
/*     */ 
/*     */   @RequestMapping(value={"find/brandId/{brandId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfBrandId(HttpServletRequest request, HttpServletResponse response, @PathVariable("brandId") Integer brandId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  40 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  42 */       Map params = new HashMap();
/*  43 */       params.put("brandId", brandId);
/*  44 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/*  45 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  47 */       ResponseUtils.setErrorMsgResponse(
/*  48 */         RequestUtils.getFindDataErrorMessage(request), response);
/*  49 */       logger.error(e);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/brandId/brandId"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getBrandId(HttpServletRequest request, HttpServletResponse response, @PathVariable("brandId") Long brandId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  58 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  60 */       GsonEbRst gsonEbRst = this.dao.getGsonOfBrandId(brandId);
/*  61 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  63 */       ResponseUtils.setErrorMsgResponse(
/*  64 */         RequestUtils.getFindDataErrorMessage(request), response);
/*  65 */       logger.error(e);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/manuId/{manuId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfManuId(HttpServletRequest request, HttpServletResponse response, @PathVariable("manuId") Integer manuId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  74 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  76 */       GsonEbRst gsonEbRst = this.dao.getGsonOfManuId(manuId, nPageIdx, nPageSize);
/*  77 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  79 */       ResponseUtils.setErrorMsgResponse(
/*  80 */         RequestUtils.getFindDataErrorMessage(request), response);
/*  81 */       logger.error(e);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/id"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getId(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*  97 */     Long id = RequestUtils.getLong(request, "id");
/*     */     try {
/*  99 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(id);
/* 100 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 102 */       logger.error(e);
/* 103 */       ResponseUtils.setErrorMsgResponse(
/* 104 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/manuId/all/{manuId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfManuIdAllPage(HttpServletRequest request, HttpServletResponse response, @PathVariable("manuId") Integer manuId)
/*     */   {
/*     */     try
/*     */     {
/* 113 */       GsonEbRst gsonEbRst = this.dao.getGsonOfManuId(manuId);
/* 114 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 116 */       ResponseUtils.setErrorMsgResponse(
/* 117 */         RequestUtils.getFindDataErrorMessage(request), response);
/* 118 */       logger.error(e);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/brandId/all/{brandId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfBrandIdAllPage(HttpServletRequest request, HttpServletResponse response, @PathVariable("brandId") Integer brandId)
/*     */   {
/*     */     try {
/* 126 */       GsonEbRst gsonEbRst = this.dao.getGsonOfBrandId(brandId);
/* 127 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 129 */       ResponseUtils.setErrorMsgResponse(
/* 130 */         RequestUtils.getFindDataErrorMessage(request), response);
/* 131 */       logger.error(e);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/all/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAll(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/* 146 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/* 148 */       Map params = new HashMap();
/* 149 */       MapUtils.addToMap(params, "id", RequestUtils.getLong(request, "id"));
/* 150 */       MapUtils.addToMap(params, "brandId", RequestUtils.getLong(request, "brandId"));
/* 151 */       MapUtils.addPercentToMap(params, "name", 
/* 152 */         RequestUtils.getString(request, "name"));
/* 153 */       MapUtils.addToMap(params, "code", 
/* 154 */         RequestUtils.getString(request, "code"));
/* 155 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/* 156 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 158 */       logger.error(e);
/* 159 */       ResponseUtils.setErrorMsgResponse(
/* 160 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/all"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAll(HttpServletRequest request, HttpServletResponse response) {
/*     */     try {
/* 167 */       Map params = new HashMap();
/* 168 */       MapUtils.addToMap(params, "id", RequestUtils.getLong(request, "id"));
/* 169 */       MapUtils.addToMap(params, "brandId", RequestUtils.getLong(request, "brandId"));
/* 170 */       MapUtils.addPercentToMap(params, "name", 
/* 171 */         RequestUtils.getString(request, "name"));
/* 172 */       MapUtils.addToMap(params, "code", 
/* 173 */         RequestUtils.getString(request, "code"));
/* 174 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params);
/* 175 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 177 */       logger.error(e);
/* 178 */       ResponseUtils.setErrorMsgResponse(
/* 179 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"insert"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 195 */     String sGsonInData = request.getParameter("data");
/*     */     try {
/* 197 */       int nResult = 0;
/* 198 */       ParserDataSetJson p = ParserDataSetJson.fromString(sGsonInData);
/* 199 */       if (p != null) {
/* 200 */         nResult = this.dao.applyUpdates(p);
/* 201 */         if (nResult > 0)
/* 202 */           DbConnection.commit();
/*     */         else {
/* 204 */           DbConnection.rollback();
/*     */         }
/*     */       }
/* 207 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 208 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 209 */         response);
/* 210 */       DbConnection.commit();
/*     */     } catch (Exception e) {
/* 212 */       DbConnection.rollback();
/* 213 */       logger.error(e);
/* 214 */       ResponseUtils.setErrorMsgResponse(
/* 215 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 216 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 232 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 234 */       String[] strParams = id.split(",");
/* 235 */       int nResult = this.dao.deleteParams(strParams);
/* 236 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 237 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 238 */         response);
/* 239 */       DbConnection.commit();
/*     */     } catch (Exception e) {
/* 241 */       DbConnection.rollback();
/* 242 */       logger.error(e);
/* 243 */       ResponseUtils.setErrorMsgResponse(
/* 244 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 245 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional(rollbackFor={Exception.class})
/*     */   @RequestMapping(value={"edit"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 261 */     String sData = RequestUtils.getStringOfData(request);
/*     */     try {
/* 263 */       int nResult = 0;
/* 264 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 265 */       if (p != null) {
/* 266 */         nResult = this.dao.applyUpdates(p);
/* 267 */         if (nResult > 0)
/* 268 */           DbConnection.commit();
/*     */         else {
/* 270 */           DbConnection.rollback();
/*     */         }
/*     */       }
/*     */ 
/* 274 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 275 */         RequestUtils.getSqlUpdateErrorMessage(sData, request), 
/* 276 */         response);
/*     */     } catch (Exception e) {
/* 278 */       DbConnection.rollback();
/* 279 */       logger.error(e);
/* 280 */       ResponseUtils.setErrorMsgResponse(
/* 281 */         RequestUtils.getSqlUpdateErrorMessage(sData, request) + 
/* 282 */         ":" + e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.info.carSystem.controller.CarSystemController
 * JD-Core Version:    0.5.3
 */